import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'
import { DepositListComponent } from './list/list.component'
import { DepositDetailComponent } from './detail/detail.component'
import { DepositDetailTabBizComponent } from './detail/tab-biz/tab-biz.component'
import { DepositDetailTabLogsComponent } from './detail/tab-logs/tab-logs.component'
import { DepositCollectionComponent } from './new/collection.component'
import { DepositReturnComponent } from './new/return.component'
import { NewRouterGuardClass } from '@shared/classes/NewRouterGuardClass'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass'

const routes: Routes = [
  { path: '', redirectTo: 'list', pathMatch: 'full' },
  {
    path: 'list',
    component: DepositListComponent,
    canActivate: [ListReuseGuardClass],
    data: {
      breadcrumb: 'OPERATION.DEPOSIT.LIST',
      title: '商户保证金',
      titleI18n: 'OPERATION.DEPOSIT.LIST',
      pathMatch: 'full',
      reuse: true,
    },
  },
  {
    path: 'new/collection',
    component: DepositCollectionComponent,
    canDeactivate: [NewRouterGuardClass],
    data: {
      breadcrumb: 'OPERATION.DEPOSIT.COLLECT',
      title: '收取保证金',
      titleI18n: 'OPERATION.DEPOSIT.COLLECT',
      pathMatch: 'full',
    },
  },
  {
    path: 'new/return',
    component: DepositReturnComponent,
    canDeactivate: [NewRouterGuardClass],
    data: {
      breadcrumb: 'OPERATION.DEPOSIT.RETURN',
      title: '返还保证金',
      titleI18n: 'OPERATION.DEPOSIT.RETURN',
      pathMatch: 'full',
    },
  },
  {
    path: ':id',
    children: [
      { path: '', redirectTo: 'biz', pathMatch: 'full' },
      {
        path: 'biz',
        component: DepositDetailTabBizComponent,
        data: {
          titleI18n: 'OPERATION.DEPOSIT.TITLE.DETAIL',
        },
      },
      {
        path: 'logs',
        component: DepositDetailTabLogsComponent,
        data: {
          titleI18n: 'OPERATION.DEPOSIT.TITLE.DETAIL',
        },
      },
    ],
    component: DepositDetailComponent,
    data: {
      breadcrumb: 'OPERATION.DEPOSIT.TITLE.DETAIL',
      title: '商户保证金详情',
      titleI18n: 'OPERATION.DEPOSIT.TITLE.DETAIL',
    },
  },
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class DepositRoutingModule {}
